package com.yanqu.road.dataHelper.action;

import com.yanqu.road.dataHelper.action.excel.AddIpInfoLogin;
import com.yanqu.road.dataHelper.gameServer.GameServer;
import com.yanqu.road.dataHelper.ipdb.City;
import com.yanqu.road.dataHelper.manager.ServerMgr;
import com.yanqu.road.entity.servercenter.ServerInfo;
import com.yanqu.road.utils.redis.JedisHelper;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class IpAddressAddExcel  extends actionBase{
    public void go(List<Long> serverList){
        try {
            String dirPath = System.getProperty("user.dir") + File.separator + "config" + File.separator +"redis.properties";
            JedisHelper jedisUtils = JedisHelper.getInstance(dirPath);
            City cityDb = new City("/data/www/wwwroot/back/java/config/ipv4.ipdb");
            for (Long serverId : serverList) {
                ServerInfo serverInfo = ServerMgr.getServerInfoList().get(serverId);
                if (serverInfo != null) {
                    AddIpInfoLogin login = new AddIpInfoLogin(new GameServer(serverInfo));
                    login.go(cityDb,jedisUtils);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
